import axios from '../utils/axios'
// import City from '../../dbs/models/city'
module.exports = async (ctx) => {
  // 方法1：查询数据库
  // const city = await City.find()
  // ctx.body = {
  //   city
  // }

  // 方法二：查询线上服务
  const {
    status,
    data: {
      city
    }
  } = await axios.get('http://cp-tools.cn/geo/city')
  if (status === 200) {
    ctx.body = {
      code: 0,
      city
    }
  } else {
    ctx.body = {
      code: -1,
      city: ''
    }
  }
}
